package com.fuhao.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.FlushMode;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.fuhao.dao.BaseDao;
import com.fuhao.entity.Customer;
import com.fuhao.entity.Person;

@Repository
public class TestDao extends HibernateDaoSupport implements BaseDao<Person>{

/*	@Resource  
    public void setMySessionFactory(SessionFactory sessionFactory){  
        super.setSessionFactory(sessionFactory);  
    }  */
	
	@Resource(name="sessionFactory")
	public void setSuperSessionFactory(SessionFactory sessionFactory){
		super.setSessionFactory(sessionFactory);
	}

	public void save(Person person) {
		getHibernateTemplate().save(person);
	}

	public Person get(Class<?> clazz, Integer id) {
		return null;
	}

	public void update(Person entity) {
		// TODO Auto-generated method stub
		
	}

	public void delete(Person entity) {
		// TODO Auto-generated method stub
		
	}

	public void saveOrUpdate(Person entity) {
		// TODO Auto-generated method stub
		
	}

	public List<Person> find(String queryName, String[] paramNames, Object[] values) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Person> findByPage(String hql, int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Person> findByPage(String hql, int pageNo, int pageSize, String[] params, String[] values) {
		// TODO Auto-generated method stub
		return null;
	}


	public void test() {
		Customer customer = new Customer();
		customer.setCustomerName("aa");
		
		com.fuhao.entity.Order order1 = new com.fuhao.entity.Order();
		order1.setOrderName("ORDER-1");
		
		com.fuhao.entity.Order order2 = new com.fuhao.entity.Order();
		order2.setOrderName("ORDER-2");
		
		order1.setCustomer(customer);
		order2.setCustomer(customer);
		
		this.getHibernateTemplate().save(customer);
		this.getHibernateTemplate().save(order1);
		this.getHibernateTemplate().save(order2);
	}
	
}
